/**
 * Created by denh on 16/12/20.
 */
var token = "<?=$_SESSION['app_token']?>";

//上传头像
$("body").on('change', "#uploadPic", function(){
    var file = $('#uploadPic').get(0).files[0];
    if(file.size > 1048576){
        alert('图片上传失败,图片大小超过1M');
        return false;
    }
    common.indexUrl = "<?=G_SITE_BASE?>/index.php";
    var url = common.url('api', 'uploadToQiniu', 'fileName=uploadPic');
    common.upload(url, 'uploadPic', function(re) {
        console.log(re);
        url = common.qiniuUrl+re.datas.key;
        console.log(url);
        $("#pt_pic").val(url);

        $("#pic_view").attr('src', url).parent().show();
    });
});


$("#isForAllUser").change(function(){
    if ($(this).val() == '0') {
        $(".filter").show();
    } else {
        $(".filter").hide();
    }
});